#include "Color4.h"
#include <cassert>

namespace Core {
	// Constructors
	Color4::Color4() {
	}

	Color4::Color4( float r, float g, float b, float a )
		: r(r), g(g), b(b), a(a) {
	}

	Color4::Color4( float const (&arr)[4] )
		: r(arr[0]), g(arr[1]), b(arr[2]), a(arr[3]) {
	}

	// Named constructors
	Color4 Color4::gray( float val, float a /*= 1.f */ ) {
		return Color4( val, val, val, a );
	}

	// Accessors
	const float& Color4::operator[]( int idx ) const {
		assert( 0 <= idx && idx < 4 );
		return this->*map[idx];
	}

	float& Color4::operator[]( int idx ) {
		assert( 0 <= idx && idx < 4 );
		return this->*map[idx];
	}

	float Color4::* const (Color4::map[4]) = {
		&Color4::r,
		&Color4::g,
		&Color4::b,
		&Color4::a
	};
}